package com.kyivmohyla.kma2.client.view.operator;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.user.datepicker.client.DateBox;
import com.kyivmohyla.kma2.client.presenter.operator.OperatorEditOrderPresenter;
import com.kyivmohyla.kma2.client.view.common.OrderHistoryWidget;
import com.kyivmohyla.kma2.client.view.common.ServiceCellTableWidget;

public class OperatorEditOrderWindowView extends Composite implements OperatorEditOrderPresenter.Display {
    private static OperatorOrderEditWindowViewUiBinder ourUiBinder = GWT.create(OperatorOrderEditWindowViewUiBinder.class);
    private final static DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd.MM.yyyy");
    @UiField
    protected Label greeting;
    @UiField
    protected TextBox state;
    @UiField
    protected TextBox customerName;
    @UiField
    protected TextBox customerPhone;
    @UiField
    protected TextArea customerAddress;
    @UiField
    protected TextBox customerEmail;
    @UiField
    protected DateBox desirableDate;
    @UiField
    protected ListBox desirableStartTime;
    @UiField
    protected ListBox desirableEndTime;
    @UiField
    protected ServiceCellTableWidget serviceCellTable;
    @UiField
    protected TextBox myCommentary;
    @UiField
    protected TextArea commentary;
    @UiField
    protected Button manageServices;
    @UiField
    protected Button deleteOrder;
    @UiField
    protected Button saveOrder;
    //    @UiField
//    protected Button saveAndClose;
    @UiField
    protected Button cancel;
    @UiField
    protected Button accessOrder;
    @UiField
    protected Button closeOrder;
    @UiField
    protected OrderHistoryWidget orderHistoryCellTable;

    //  for input validation
    @UiField
    protected Label customerNameInfoLabel;
    @UiField
    protected Label customerAddressInfoLabel;
    @UiField
    protected Label customerEmailInfoLabel;
    @UiField
    protected Label customerPhoneInfoLabel;
    @UiField
    protected Label desirableDateInfoLabel;
    @UiField
    protected Label desirableStartTimeInfoLabel;
    @UiField
    protected Label commentaryInfoLabel;

    public OperatorEditOrderWindowView() {
        initWidget(ourUiBinder.createAndBindUi(this));
        greeting.setText("This is Order Editing Window");
        desirableDate.setFormat(new DateBox.DefaultFormat(dateFormat));
    }

    @Override
    public HasText getCustomerNameInfoLabel() {
        return customerNameInfoLabel;
    }

    @Override
    public HasText getCustomerAddressInfoLabel() {
        return customerAddressInfoLabel;
    }

    @Override
    public HasText getCustomerEmailInfoLabel() {
        return customerEmailInfoLabel;
    }

    @Override
    public HasText getCustomerPhoneInfoLabel() {

        return customerPhoneInfoLabel;
    }

    @Override
    public HasText getDesirableDateInfoLabel() {
        return desirableDateInfoLabel;
    }

    @Override
    public HasText getDesirableStartTimeInfoLabel() {
        return desirableStartTimeInfoLabel;
    }

    @Override
    public HasText getCommentaryInfoLabel() {
        return commentaryInfoLabel;
    }

    @Override
    public HasText getState() {
        return state;
    }

    @Override
    public HasText getCustomerName() {
        return customerName;
    }

    @Override
    public HasText getCustomerPhone() {
        return customerPhone;
    }

    @Override
    public HasText getCustomerAddress() {
        return customerAddress;
    }

    @Override
    public DateBox getDesirableDate() {
        return desirableDate;
    }

    @Override
    public ListBox getDesirableStartTime() {
        return desirableStartTime;
    }

    @Override
    public ListBox getDesirableEndTime() {
        return desirableEndTime;
    }

    @Override
    public HasText getMyCommentary() {
        return myCommentary;
    }

    @Override
    public HasText getCommentary() {
        return commentary;
    }

    @Override
    public HasClickHandlers getManageServicesButton() {
        return manageServices;
    }

    @Override
    public HasClickHandlers getDeleteOrderButton() {
        return deleteOrder;
    }

    @Override
    public HasText getCustomerEmail() {
        return customerEmail;
    }

    @Override
    public HasClickHandlers getSaveOrderButton() {
        return saveOrder;
    }

//    @Override
//    public HasClickHandlers getSaveAndCloseButton() {
//        return saveAndClose;
//    }

    @Override
    public HasClickHandlers getCancelButton() {
        return cancel;
    }

    @Override
    public HasClickHandlers getAccessButton() {
        return accessOrder;
    }

    @Override
    public HasClickHandlers getCloseButton() {
        return closeOrder;
    }

    @Override
    public ServiceCellTableWidget getServiceCellTable() {
        return serviceCellTable;
    }

    @Override
    public OrderHistoryWidget getOrderHistoryCellTable() {
        return orderHistoryCellTable;
    }

    public Widget asWidget() {
        return this;
    }

    interface OperatorOrderEditWindowViewUiBinder extends UiBinder<Widget, OperatorEditOrderWindowView> {
    }
}